package cn.milolab.djback.controller;

import cn.milolab.djback.annotation.DJRoleCheck;
import cn.milolab.djback.bean.entity.Employee;
import cn.milolab.djback.bean.request.AuthenticateRequest;
import cn.milolab.djback.service.AuthenticateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @author 叶欣委
 */
@RestController
@Slf4j
public class AuthenticateController {
    @Autowired
    AuthenticateService authenticateService;

    @PostMapping("/authenticate")
    @DJRoleCheck(Employee.RoleLevel.COMMON_WECHAT_USER)
    public Map<String, Object> authenticate(@RequestBody AuthenticateRequest authenticateRequest, @NonNull @RequestAttribute Integer userId) {
        log.warn(authenticateRequest.toString());
        return authenticateService.authenticate(authenticateRequest.getStuSerial(), authenticateRequest.getJobSerial(), userId);
    }
}
